import os from 'os'

export const getAllMacAddresses = () => {
  const networkInterfaces = os.networkInterfaces()
  const macAddresses = []

  for (const interfaceName in networkInterfaces) {
    const interfaces = networkInterfaces[interfaceName]

    for (const iface of interfaces) {
      // 跳过内部接口和非物理接口
      if (iface.internal || iface.mac === '00:00:00:00:00:00') continue

      macAddresses.push({
        name: interfaceName,
        mac: iface.mac,
        family: iface.family, // IPv4或IPv6
        address: iface.address // IP地址
      })
    }
  }

  return macAddresses
}
